<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
	<title>药品历史价格</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
	<style type="text/css">
    .box-body{
    margin-top:-2px;
    }    	
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>药品历史价格</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">药品调价</a></li>
            <li class="active"><a href="#">药品历史价格</a></li>
        </ol>
    </section>
    <section class="content">
       <form id="form" method="post" class="form-horizontal">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
                       <div class="textalign1">通用名：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="drugName" placeholder="通用名"/>
                       </div>
                
                       <div class="textalign">药品编码：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="drugCode" placeholder="药品编码"/>
                       </div>

					   <div class="textalign">生产企业：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput" id="prodComp" placeholder="生产企业"/>
                       </div>
  
                </div>
                <div class="input"  style="margin-top:-5px">
	                   <div class="textalign1">项目名称：</div>
	                   <div class="boxinput">
	                       <input id="projName" class="textinput" type="text" placeholder="项目名称" />
	                   </div>
                       <div class="textalign" >调价日期：</div>
                       <div class="boxinput" > 
                        <table style="width:100%;">
                                <tr>
                                    <td style="width:50%">       
                                        <input class="textinput" id='startTime' type="text" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" placeholder="yyyy-MM-dd">
						            </td>
                                    <td>&nbsp;-&nbsp;</td>
                                    <td style="width:50%">       
                                        <input class="textinput" id='endTime' type="text" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                    </td>
                                </tr>
                         </table>
						 </div>
                    <div class="textalign" >
                          <button type="button" onclick="likeQuery();" class="btn btn-success btn-sm" id="selectc">查&nbsp;询</button>
                    </div>  
                </div>
                </div>
           </div>
        </div>
        </form>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
    </section>
   <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">

		 //绑定回车
	   $('#goodsCode,#drugCode,#drugName,#prodComp,#projName,#startTime,#endTime').bind('keydown', function(event) {
	       if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
	           $('#selectc').click();
	       }
	   }); 
	   
	   $("#drugName").focus();//加载页面光标在第一个查询框上
	   
        $(function () {
            $("#gridlist").jqGrid({
                url: "getHistoryDataList.html",
                mtype: "post",
                datatype: "json",
                shrinkToFit: false,
             //   height: 301,
                colNames: ['商品编码','药品编码', '通用名',  '剂型', '规格', '转换系数', '单位', '材质','生产企业','国药准字','项目名称','采购价', '新采购价', '最高限价', '新最高限价', '调价时间','调价依据', '生产企业ID','药品ID'],
                colModel: [
					{ name: 'goodsCode', width: 100,sortable: false,align: 'center',hidden:true},
					{ name: 'drugCode', width: 100,sortable: false,align: 'center'},
                    { name: 'drugName', width: 140,sortable: false,align: 'left' },
                    { name: 'formName', width: 80 ,sortable: false,align: 'center' },
                    { name: 'specName', width: 80 ,sortable: false,align: 'left' },
                    { name: 'factor', width: 80,sortable: false,align: 'center' },
                    { name: 'unit', width: 40 ,sortable: false,align: 'center' },
					{ name: 'materialName', width: 80 ,sortable: false,align: 'center' },
                    { name: 'prodComp', width: 190,sortable: false,align: 'left'},
                    
                    { name: 'drugMedicine', width: 190,sortable: false,align: 'left'},
                    { name: 'projName', width: 190,sortable: false,align: 'left'},
                    { name: 'origProPriceLimit', width: 80,sortable: false, align: "right",
						formatter:function(cellvalue, options, row) {
						    return formatAmt(cellvalue, options, row);
						}
					},
                    { name: 'currProPriceLimit', width: 80, sortable: false,align: "right",
						formatter:function(cellvalue, options, row) {
						    return formatAmt(cellvalue, options, row);
						}
					},
                    { name: 'origRetailPriceLimit', width: 80,sortable: false, align: "right",
						formatter:function(cellvalue, options, row) {
						    return formatAmt(cellvalue, options, row);
						}
					},
                    { name: 'currRetailPriceLlimit', width: 80,sortable: false, align: "right",
						formatter:function(cellvalue, options, row) {
						    return formatAmt(cellvalue, options, row);
						}					
					},
					{ name: 'executeDatetime', index:'executeDatetime', width: 140,sortable: false,align: 'center'},
					{ name: 'priceAdjAccord', index:'priceAdjAccord', width: 200,sortable: false,align: 'center'},
					{ name: 'prodCompId',index: 'prodCompId', hidden:true, width: 180,align: 'center'},
					{ name: 'drugId',index: 'drugId', hidden:true, width: 120,align: 'center'}
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
               caption: "药品历史调价",
				gridComplete:function(){
				//序号列宽度自适应（参数为jqgridID）
				autoRNWidth("gridlist");
				//数据只有一条时默认选中（参数为jqgridID）
				selectByOneData("gridlist");
                }

            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
			$("#gridlist").jqGrid("setGridHeight", create());
        });
        
		 function formatAmt(cellvalue, options, row) {
			var f_x = Math.round(cellvalue * 100) / 100;
			var s_x = f_x.toString();
			var pos_decimal = s_x.indexOf('.');
			
			if (pos_decimal < 0) {
				pos_decimal = s_x.length;
				s_x += '.';
			}
			
			while (s_x.length <= pos_decimal + 2) {
				s_x += '0';
			}
			return s_x;
		}
						
    	function likeQuery() {
    		var goodsCode = $.trim($("#goodsCode").val());
    		var drugCode = $.trim($("#drugCode").val());
    		var drugName = $.trim($("#drugName").val());
    		var formName = $.trim($("#formName").val());
    		var specName = $.trim($("#specName").val());
    		var prodComp = $.trim($("#prodComp").val());
			var startTime = $.trim($("#startTime").val());
			var endTime = $.trim($("#endTime").val());
			$("#gridlist").jqGrid('setGridParam',{
       	    	datatype:'json',
                postData:{
                	"goodsCode":goodsCode,
                	"drugCode":drugCode,
                	"drugName":drugName,
                	"formName":formName,
                	"specName":specName,
                	"prodComp":prodComp,
					"startTime":startTime,
					"endTime":endTime
                },
                page : 1
			}).trigger("reloadGrid");
		}
    </script>
</body>
</html>